const path = require('path')
const devConfig = require('./webpack.env')
const webpack = require("webpack");

module.exports = {
    entry: {
        'agreementSDK': './src/index.js'
    },
    output: {
        path: path.resolve(__dirname, '../dist'),
        filename: '[name].js',
        publicPath: '',
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                include: path.resolve(__dirname, '../src'),
                use: 'babel-loader'
            },
            {
                test: /\.(css)$/,
                use: ['style-loader', {
                    loader: 'css-loader',
                    options: {
                        modules: true,
                        localIdentName: '[local]'
                    }
                }]
            },
            {
                test: /\.(jpg|png|gif|bmp|jpeg)$/, //正则表达式匹配图片规则
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 10000, //限制打包图片的大小：
                        esModule: false,   //如果大于或等于10000Byte，则按照相应的文件名和路径打包图片；如果小于10000Byte，则将图片转成base64格式的字符串。
                        name: 'images/[name].[hash:8].[ext]', //css中的images图片将会打包在build/image下;
                    }
                }]
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            ENV_CONFIG: devConfig,
        })
    ]
}
